package com.neutech.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.neutech.po.Dept;
import com.neutech.po.User;
import com.neutech.service.DeptService;

@Controller
@RequestMapping(value="/dept")
public class DeptController {
	@Autowired
	private DeptService deptService;
	@RequestMapping("/findDoctor")
	public @ResponseBody List<Dept> findDoctor(){
		List<Dept> list= deptService.findDoctor();
		return list;
	}
	@RequestMapping(value="/updateDoctor",method=RequestMethod.POST)
	public @ResponseBody String updateDoctor(@RequestBody Dept dept){
		dept.setDoctor_id(dept.getDoctors().get(0).getDoctor_id());
		deptService.updateDoctor(dept);
		return "修改成功";
	}
	@RequestMapping(value="/addDoctor",method=RequestMethod.POST)
	public @ResponseBody String addDoctor(@RequestBody Dept dept){
		dept.setDoctor_id(dept.getDoctors().get(0).getDoctor_id());
		System.out.println("aaa");
		deptService.addDoctor(dept);
		return "增加成功";
	}
	@RequestMapping("/delDoctor")
	public @ResponseBody String delDoctor(@RequestParam(value="id",required=true) Integer id){
		deptService.delDoctor(id);
		return "删除成功";
	}
}
